<?php
# file that will mark as accepted for group or delete them from list

# include of site functions
include_once $_SERVER["DOCUMENT_ROOT"].'Meet-n-go/php/includes.php'; 	// contains includes of all files with functions
session_start();					// starts session for current user
c_db_connect(); 					// connect to database

$group_id = $_GET['group_id'];
$part_id = $_GET['id'];
$action = intval($_GET['action']);

if($action == 1){ // accept - set status to 1
	$query = "UPDATE participants SET STATUS = 1 WHERE USER_ID = '$part_id' AND GROUP_ID = '$group_id'";
	$result = c_db_query($query);
	if(!$result) i_set_msg_err('Error accepting participant');
}
elseif($action == 0){ // decline - delete from participants list
	$query = "DELETE FROM participants WHERE USER_ID = '$part_id' AND GROUP_ID = '$group_id'";
	$result = c_db_query($query);
	if(!$result) i_set_msg_err('Error declyining participant');
}

c_db_disconnect(); 					// disconnect from database

# Where to go after processing
$page_id = I_GROUP_OVERVIEW."&grp=$group_id";

# code that makes sure, this page is being redirected from afterwards
echo '<head><meta http-equiv="refresh" content="0; url=../../../index.php?id=' . $page_id . '" /></head>';


?>